{% load i18n future wenlincms_tags wlcore_tags %}

<div id="side-panel">
    <div class="dropdown-menu">
        <ul>
            {% for app in dropdown_menu_app_list %}
                <li>
                    <a href="#">{% trans app.name %}</a>
                    <ul class="dropdown-menu-menu">
                        {% for model in app.models %}
                            {% if model.perms.add or model.perms.change or model.perms.custom %}
                                {% if model.name == "媒体库" and not user.is_superuser %}
                                {% else %}
                                    <li{% if forloop.first %} class="first"{% endif %}><a href="{% wlspaceless %}
                                    {{ model.admin_url }}
                                    {% if not model.perms.change and not model.perms.custom %}add/{% endif %}
                                    {% endwlspaceless %}">{{ model.name }}</a>
                                    </li>
                                {% endif %}
                            {% endif %}
                        {% endfor %}
                        {% if user.is_superuser %}
                            {% if forloop.last %}
                                <li><a href="/core/wllog/uwsgi.log/800/">系统日志</a></li>
                            {% endif %}
                        {% endif %}
                    </ul>
                </li>
            {% endfor %}
        </ul>

        {% if settings.USE_L10N and LANGUAGES|length > 1 %}
            {% get_language_info_list for LANGUAGES as languages %}
            <form>
                <select id="id_language" onchange="window.location.href=this.value;">
                    {% for lang in languages %}
                        <option{% if LANGUAGE_CODE == lang.code %} selected="selected"{% endif %}
                                                                   value="{% translate_url lang.code %}">{{ lang.name_local }}</option>
                    {% endfor %}
                </select>
            </form>
        {% endif %}

        {% if dropdown_menu_sites and dropdown_menu_sites|length > 1 %}
            <form action="{% url "set_site" %}">
                <input type="hidden" name="next" value="{{ request.path }}">
                <select name="site_id" onchange="this.form.submit();">
                    {% for site in dropdown_menu_sites %}
                        <option value="{{ site.id }}"
                                {% if site.id == dropdown_menu_selected_site_id %} selected{% endif %}
                        >{{ site }}</option>
                    {% endfor %}
                </select>
            </form>
        {% endif %}
    </div>
    <div id="side-panel-toggle"></div>
</div>
